﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace SecurityAgent
{
    [ServiceContract]
    public interface IMembershipProviderService
    {
        #region properties
        [OperationContract]
        bool GetEnablePasswordReset(string applicationKey);

        [OperationContract]
        bool GetEnablePasswordRetrieval(string applicationKey);

        [OperationContract]
        int GetMinRequiredPasswordLength(string applicationKey);

        [OperationContract]
        int GetPasswordAttemptWindow(string applicationKey);

        [OperationContract]
        int GetPasswordFormat(string applicationKey);

        [OperationContract]
        string GetPasswordStrengthRegularExpression(string applicationKey);

        [OperationContract]
        bool GetRequiresQuestionAndAnswer(string applicationKey);

        [OperationContract]
        bool GetRequiresUniqueEmail(string applicationKey);

        [OperationContract]
        int GetMaxInvalidPasswordAttempt(string applicationKey);

        [OperationContract]
        int GetMinRequiredNonAlphanumericCharacters(string applicationKey);


        #endregion

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        bool ChangePassword(string applicationKey, string username, string oldPassword, string newPassword);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        bool ChangePasswordQuestionAndAnswer(string applicationKey, string username, string password, string newPasswordQuestion, string newPasswordAnswer);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipal CreateUser(string applicationKey, string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
         bool DeleteUser(string applicationKey, string operatorToken, string username, bool deleteAllRelatedData);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipalCollection FindUsersByEmail(string applicationKey, string emailToMatch, int pageIndex, int pageSize, out int totalRecords);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipalCollection FindUsersByName(string applicationKey, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
         SecurityPrincipalCollection GetAllUsers(string applicationKey, string operatorToken, int pageIndex, int pageSize, out int totalRecords);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         int GetNumberOfUsersOnline(string applicationKey);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         string GetPassword(string applicationKey, string username, string answer);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipal GetUserByUserName(string applicationKey, string username, bool userIsOnline);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipal GetUserByKey(string applicationKey, object providerUserKey, bool userIsOnline);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         string GetUserNameByEmail(string applicationKey, string email);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         string ResetPassword(string applicationKey, string username, string answer);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
         bool UnlockUser(string applicationKey, string operatorToken, string userName);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(UnauthorizedAccessFault))]
         void UpdateUser(string applicationKey, string operatorToken, string userName, SecurityPrincipal user);
        
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         bool ValidateUser(string applicationKey, string username, string password);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         string ValidateAndRegisterUser(string applicationKey, string username, string password);

        #region AdditionalOperations
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
         SecurityPrincipal ObtainServiceUserByToken(string serviceApp, object userToken);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        bool ExpireToken(string applicationKey, object userToken);

        #endregion

    }

    //
}
